#!/bin/bash

ROOTDIR=$1

TMPDIR=/tmp/mkiso

rm -rf $TMPDIR
if [ ! -d $TMPDIR ]; then
    mkdir -p $TMPDIR
fi

PLAT=-x64

if [ "$ROOTDIR" == "" ]; then
    ROOTDIR=betainitrd
fi

echo "gen init ramfs list ... "
./gen_initramfs_list.sh $ROOTDIR/ > $TMPDIR/filelist
echo "gen init cpio to get initrd...."
./gen_init_cpio$PLAT $TMPDIR/filelist > $TMPDIR/initrd
echo "gzip initrd ..."
rm initrd.gz -rf
gzip $TMPDIR/initrd

echo "copy initrd.gz to myiso/kernel ..."
mv $TMPDIR/initrd.gz myiso/kernel
echo "copy down ..."

